package com.atguigu.gulimall.seckill.web;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.seckill.service.SeckillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author ming
 * @create 2022/5/14
 * @description:
 */
@Controller
public class WebController {
    @Autowired
    private SeckillService seckillService;
    @GetMapping("/kill")
    public String seckKill(@RequestParam("killId") String killId,
                           @RequestParam("key") String key,
                           @RequestParam("num") Integer num,
                           Model model
                           ){
        //判断是否登录
        String orderSn = seckillService.kill(killId,key,num);
        model.addAttribute("orderSn", orderSn);
        return "success";
    }
}
